using System;
using System.Windows.Forms;
using App.Controlador.Seguridad;
using App.Modelo;

namespace App.Git.Vista
{
    public partial class CrearTarea : Form
    {
        public Tarea Tarea
        {
            get
            {
                return tareaBindingSource.DataSource is Tarea
                    ? (Tarea)tareaBindingSource.DataSource
                    : null;
            }
            set
            {
                tareaBindingSource.DataSource = value;
            }
        }

        public CrearTarea()
        {
            Registry.Instance.RegisterForm(this);
            InitializeComponent();
            dateTimePicker1.Value = DateTime.Now;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Validate();
            DialogResult = DialogResult.OK;
            Hide();
        }


        public Tarea GetTarea()
        {
            Tarea = new Tarea() { Usuario = Registry.Instance.UsuarioActual };

            ShowDialog();

            return DialogResult == DialogResult.OK ? Tarea : null;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Hide();
        }
    }
}